package com.dragon.repository.domain.vo;

import com.dragon.common.model.Update;
import com.dragon.common.util.BeanUtils;
import com.dragon.repository.entity.PlanCollect;
import com.dragon.repository.entity.WorkflowJson;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotNull;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;


/**
 * @author sy
 */
@Data
@ApiModel(value = "")
public class PlanCollectVO {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "id")
    private Integer id;

    @ApiModelProperty(value = "合同id")
    private Integer contractId;

    @ApiModelProperty(value = "收款期数")
    private Integer num;

    @ApiModelProperty(value = "计划收款金额")
    private Double planMoney;

    @ApiModelProperty(value = "退款金额")
    private Double refundMoney;

    @ApiModelProperty(value = "计划收款方式：1银行卡 2微信 3支付宝")
    private Integer planType;

    @ApiModelProperty(value = "删除标识：0未删除 1已删除")
    private Integer deleted;

    @ApiModelProperty(value = "状态：0 待审核 1审核通过 2审核不通过 3作废 4删除")
    private Integer status;

    @ApiModelProperty(value = "计划收款日期")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private Date planTime;

    @ApiModelProperty(value = "创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createTime;

    @ApiModelProperty(value = "更新时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date updateTime;

    @ApiModelProperty(value = "负责人id（用户id）")
    private Integer adminId;

    @ApiModelProperty(value = "部门id")
    private Integer departmentId;

    @ApiModelProperty(value = "备注")
    private String remark;

    @ApiModelProperty(value = "实际收款金额")
    private Double actualPlanMoney;

    @ApiModelProperty(value = "收款完成状态: 0未完成 1已完成")
    private Integer planStatus;

    @ApiModelProperty(value = "单笔收款金额")
    private Double money;

    @ApiModelProperty(value = "计划收款类型：0普通收款，1：计划收款")
    private Integer planPayType;

    @ApiModelProperty(value = "计划收款账号")
    private String account;

    @ApiModelProperty(value = "工作流")
    private List<WorkflowJson> workflowJsonList;

    @ApiModelProperty(value = "平账状态：0否 1是")
    private Integer balancingAccounts;

    @ApiModelProperty(value = "平账金额")
    private Double balancingMoney;

    @ApiModelProperty(value = "账单状态：0未生成 1已生成")
    private Integer billStatus;

    @ApiModelProperty(value = "账单id")
    private Integer billId;

    @ApiModelProperty(value = "结算方式 1现结 2月结")
    private Integer settlementType;

    @ApiModelProperty(value = "免审字段：0不免审，1免审")
    private Integer exempt;

    @ApiModelProperty(value = "客户名称")
    private String customerName;

    @NotNull(groups = Update.class,message = "主键不能为空")
    public static PlanCollect convert(PlanCollectVO vo) {
        PlanCollect entity = new PlanCollect();
        BeanUtils.copyProperties(vo,entity);
        return entity;
    }
    public static List<PlanCollect> convertList(List<PlanCollectVO> list) {
        List<PlanCollect> resultList = new ArrayList<>();
        for (PlanCollectVO vo : list) {
            resultList.add(convert(vo));
        }
        return resultList;
    }
}
